from flask import Blueprint, session, request, url_for, redirect

# 创建蓝图对象，来代替app 对象
admin_blu = Blueprint("admin",__name__,url_prefix='/admin')


from . import viwe

# 添加普通用户直接访问管理员权限BUG
@admin_blu.before_request
def before_request():
    # 发起管理界面路由前，校验是否有管理员权限
    is_admin = session.get('is_admin',False)
    if not is_admin and not request.url.endswith(url_for('admin.login')):
        return redirect('/')